import 'package:gold/generated/json/base/json_convert_content.dart';
import 'package:gold/model/user_list_model.dart';
import 'package:gold/model/user_model.dart';


UserListModel $UserListModelFromJson(Map<String, dynamic> json) {
  final UserListModel userListModel = UserListModel();
  final List<SearchUserModel>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<SearchUserModel>(e) as SearchUserModel).toList();
  if (data != null) {
    userListModel.data = data;
  }
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    userListModel.total = total;
  }
  final int? count = jsonConvert.convert<int>(json['count']);
  if (count != null) {
    userListModel.count = count;
  }
  final int? perPage = jsonConvert.convert<int>(json['per_page']);
  if (perPage != null) {
    userListModel.perPage = perPage;
  }
  final int? currentPage = jsonConvert.convert<int>(json['current_page']);
  if (currentPage != null) {
    userListModel.currentPage = currentPage;
  }
  final int? totalPages = jsonConvert.convert<int>(json['total_pages']);
  if (totalPages != null) {
    userListModel.totalPages = totalPages;
  }
  return userListModel;
}

Map<String, dynamic> $UserListModelToJson(UserListModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  data['total'] = entity.total;
  data['count'] = entity.count;
  data['per_page'] = entity.perPage;
  data['current_page'] = entity.currentPage;
  data['total_pages'] = entity.totalPages;
  return data;
}

extension UserListModelExtension on UserListModel {
  UserListModel copyWith({
    List<SearchUserModel>? data,
    int? total,
    int? count,
    int? perPage,
    int? currentPage,
    int? totalPages,
  }) {
    return UserListModel()
      ..data = data ?? this.data
      ..total = total ?? this.total
      ..count = count ?? this.count
      ..perPage = perPage ?? this.perPage
      ..currentPage = currentPage ?? this.currentPage
      ..totalPages = totalPages ?? this.totalPages;
  }
}

SearchUserModel $SearchUserModelFromJson(Map<String, dynamic> json) {
  final SearchUserModel searchUserModel = SearchUserModel();
  final int? uid = jsonConvert.convert<int>(json['uid']);
  if (uid != null) {
    searchUserModel.uid = uid;
  }
  final String? nickname = jsonConvert.convert<String>(json['nickname']);
  if (nickname != null) {
    searchUserModel.nickname = nickname;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    searchUserModel.avatar = avatar;
  }
  final UserInfo? user = jsonConvert.convert<UserInfo>(json['user']);
  if (user != null) {
    searchUserModel.user = user;
  }
  return searchUserModel;
}

Map<String, dynamic> $SearchUserModelToJson(SearchUserModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['uid'] = entity.uid;
  data['nickname'] = entity.nickname;
  data['avatar'] = entity.avatar;
  data['user'] = entity.user?.toJson();
  return data;
}

extension SearchUserModelExtension on SearchUserModel {
  SearchUserModel copyWith({
    int? uid,
    String? nickname,
    String? avatar,
    UserInfo? user,
  }) {
    return SearchUserModel()
      ..uid = uid ?? this.uid
      ..nickname = nickname ?? this.nickname
      ..avatar = avatar ?? this.avatar
      ..user = user ?? this.user;
  }
}